import { Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { NoticeEntity } from '../entity/notice';

/**
 * 公告
 */
@Provide()
export class NoticeService extends BaseService {
    @InjectEntityModel(NoticeEntity)
    noticeEntity: Repository<NoticeEntity>;

    /**
     * 获取公告
     */
    async getNotice() {
        try {
            const list = await this.noticeEntity.find({
                where: {
                    status: 1
                }
            });
            return {
                success: true,
                message: '查询成功',
                data: list,
            }
        } catch (error) {
            throw new Error(error);
        }
    }
}
